package lk.service.blogspringboot.service.impl;

import lk.service.blogspringboot.domain.ArticleShareDetail;
import lk.service.blogspringboot.mapper.ArticleShareDetailMapper;
import lk.service.blogspringboot.service.ArticleShareDetailService;
import lk.service.blogspringboot.util.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 文章分享详细信息表(ArticleShareDetail)表服务实现类
 *
 * @author LK
 * @since 2024-08-22 10:33:41
 */
@Service("articleShareDetailService")
public class ArticleShareDetailServiceImpl implements ArticleShareDetailService {
    @Resource
    private ArticleShareDetailMapper articleShareDetailMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public R queryById(Integer id) {
        return R.ok().setData(this.articleShareDetailMapper.queryById(id));
    }

    /**
     * 全查询
     *
     * @param articleShareDetail 筛选条件
     * @return 查询结果
     */
    @Override
    public R queryAll(ArticleShareDetail articleShareDetail) {
        return R.ok().setData(this.articleShareDetailMapper.queryAll(articleShareDetail));
    }

    /**
     * 新增数据
     *
     * @param articleShareDetail 实例对象
     * @return 实例对象
     */
    @Override
    public R insert(ArticleShareDetail articleShareDetail) {
        this.articleShareDetailMapper.insert(articleShareDetail);
        return R.ok().setData(articleShareDetail);
    }

    /**
     * 修改数据
     *
     * @param articleShareDetail 实例对象
     * @return 实例对象
     */
    @Override
    public R update(ArticleShareDetail articleShareDetail) {
        this.articleShareDetailMapper.update(articleShareDetail);
        return R.ok().setData(this.queryById(articleShareDetail.getId()));
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public R deleteById(Integer id) {
        boolean del = this.articleShareDetailMapper.deleteById(id) > 0;
        return R.ok().setData(del);
    }
}

